<?xml version="1.0"?>
<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" xmlns:html="http://www.w3.org/1999/xhtml">
  <atom:id>http://caudium.net/atom/documentation/PHP Setup</atom:id>
  <atom:title type="text">Caudium :: PHP Setup</atom:title>
  <atom:updated>2026-07-18T06:15:15-04:00</atom:updated>
  <atom:link href="http://caudium.net/atom/documentation/PHP Setup" type="application/atom+xml"></atom:link>
  <atom:link href="http://caudium.net/space/documentation/PHP Setup" type="text/html"></atom:link>
  <atom:link href="http://caudium.net/rss/documentation/PHP Setup" type="application/rss+xml"></atom:link>
  <atom:generator uri="http://modules.gotpike.org/blahblah/Public.Syndication.ATOM" version="0.1">Public.Syndication.ATOM (Pike v8.0 release 1956)</atom:generator>
  <atom:icon>http://caudium.net/favicon.ico</atom:icon>
  <atom:logo>http://caudium.net/caudium.png</atom:logo>
  <atom:subtitle type="xhtml"><html:div xmlns:html="http://www.w3.org/1999/xhtml"><html:h2>
1. Introduction&#xA0;
</html:h2>
There are two recommended ways to run PHP with Caudium. Each way has its advantages and drawbacks.
<html:br/>
<html:br/>
PHP can be run:&#xA0;
<html:br/>
<html:ul>
	<html:li style="min-height: 1.2em;">
		As a CGI, using Caudium Uniscript module.
	</html:li>
	<html:li style="min-height: 1.2em;">
		As a FastCGI, using Caudium FastUniscript module.
	</html:li>
</html:ul>
<html:br/>
Both methods are similar, simply compile your PHP with support for FastCGI to use the second option and replace FastUniscript in the instructions.&#xA0; A third method using PHP as a module is&#xA0;not supported anymore&#xA0;due to PHP bugs. Read further for more information
<html:br/>
<html:br/>
<html:h2>
2. PHP using Uniscript
</html:h2>
<html:h3>
2.1. Introduction to Uniscript Mode
</html:h3>
<html:br/>
Uniscript mode is in fact using PHP in CGI mode. Caudium has a module named&#xA0;Universal Script Parser&#xA0;that allows you to wrap any special extensions inside a webserver to a&#xA0;CGI. Eg&#xA0;.php&#xA0;to&#xA0;/usr/local/bin/php. This is the way PHP will be run.
<html:br/>
<html:br/>
<html:h3>
2.2. Drawbacks
</html:h3>
<html:ul>
	<html:li>
		A PHP interpreter is forked on each page called. This can be ressource consuming.
	</html:li>
	<html:li>
		Some PHP options and some security options must be considered. See the&#xA0;PHP manual&#xA0;about PHP install as a CGI manual.
	</html:li>
</html:ul>
<html:h3>
2.3. Benefits
</html:h3>
<html:ul>
	<html:li>
		Since it is in a CGI, when PHP crashes Caudium doesn't :).
	</html:li>
	<html:li>
		You can run PHP as a user different than Caudium.
	</html:li>
	<html:li>
		You can give specify limitation on the size of processes and resources usage.
	</html:li>
	<html:li>
		You can have several PHP interpreters with different&#xA0;php.ini&#xA0;files and compilations.
	</html:li>
</html:ul>
<html:h3>
2.4. Software requirements
</html:h3>
Before installing PHP4 support as a CGI for Caudium, you will need the following:
<html:ul>
	<html:li>
		An OS supported by PHP4 and Caudium.
	</html:li>
	<html:li>
		Caudium installed (you&#xA0;don't&#xA0;need Pike development headers).
	</html:li>
	<html:li>
		PHP4 sources (we recommend PHP 4.3.2RC2)
	</html:li>
	<html:li>
		An ANSI C compiler and all libraries needed for compiling PHP.
	</html:li>
</html:ul>
<html:br/>
We assume that you have successfully installed Pike and Caudium on your machine.
<html:br/>
<html:br/>
<html:h3>
2.5. Compilation and installation of PHP
</html:h3>
<html:br/>
NOTE: in this example, we assume that we will install all PHP in&#xA0;/usr/local/php-4.3.2RC-cgi/.
<html:br/>
Extract PHP4 source somewhere and do the following :
<html:br/>
<html:br/>
&#xA0;
<html:div class="code"><html:pre><html:pre>
 $ cd php-4.3.2RC2
 $ ./configure --prefix=/usr/local/php-4.3.2RC-cgi/ --enable-force-cgi-redirect \
               --enable-discard-path --enable-fastcgi --without-pear --enable-safe-mode \
               --enable-sigchild --enable-magic-quotes --disable-rpath \
               --with-other-php-options
 $ make
</html:pre></html:pre></html:div>

Now the PHP interpreter is fully compiled and can be installed.
<html:br/>

	<html:br/>
<html:div class="code"><html:pre><html:pre>
 $ make install
</html:pre></html:pre></html:div>

	<html:br/>
	<html:br/>
<html:h3>
2.6. Configuring Caudium
</html:h3>
Log into the graphical configuration interface and go to the virtual server where you want to add PHP support.&#xA0;&#xA0;
<html:br/>
<html:br/>
Click on "Add Module", locate and add PATH_INFO support module and Universal Script parser module.&#xA0;
<html:br/>
<html:br/>
Then configure the Universal Script Parser module with the following options :
<html:br/>
<html:br/>
<html:ul>
	<html:li>
		interpreter path :&#xA0;/usr/local/php-4.3.2RC-cgi/bin/php&#xA0;or the place where where you have installed php. &#xA0;
	</html:li>
	<html:li>
		script extensions :&#xA0;php&#xA0;or comma separated extensions you'd like to handle with that php cgi. &#xA0;
	</html:li>
</html:ul>
<html:br/>
Note that you can configure the&#xA0;<html:i>Run script as</html:i>&#xA0;option if you want to run php with a different user than default:nobody.&#xA0;
<html:br/>
<html:br/>
Then create a test page with :
<html:br/>
<html:br/>
<html:div class="code"><html:pre><html:pre>
&lt;? phpinfo(); ?&gt;
</html:pre></html:pre></html:div>

<html:br/>
&#xA0;&#xA0;
<html:br/>
Then you will get the PHP Info page.
<html:br/>
<html:br/>
<html:h3>
2.7. Hints
</html:h3>
To use sessions in CGI mode you will need to save them on disk instead of memory. To do that, you will need to change/add option in you&#xA0;/usr/local/php-4.3.2RC-cgi/lib/php.ini:
<html:br/>
&#xA0;
<html:div class="code"><html:pre><html:pre>
[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler.  In the <html:font color="black">case</html:font> of files, this is the path
; where data files are stored. Note<html:font color="black">:</html:font> Windows users have to change this 
; variable in order to use PHP's session <html:b><html:font color="darkgreen">function</html:font></html:b><html:b><html:font color="darkbrown">s.</html:font></html:b>
; As of PHP 4.0.1, you can define the path as:
;     session.save_path = <html:i><html:font color="darkred">"N;/path"</html:font></html:i>
; where N is an <html:b><html:font color="darkgreen">int</html:font></html:b><html:b><html:font color="darkbrown">eger.</html:font></html:b>  Instead of storing all the session files in 
; /path, what this will <html:b><html:font color="darkblue">do</html:font></html:b> is use subdirectories N-levels deep, and 
; store the session data in those directories.  This is useful <html:b><html:font color="darkblue">if</html:font></html:b> you 
; or your OS have problems with lots of files in one directory, and is 
; a more efficient layout <html:b><html:font color="darkblue">for</html:font></html:b> servers that handle lots of sessions.
; NOTE 1: PHP will not create this directory structure automatically.
;         You can use the script in the ext/session dir <html:b><html:font color="darkblue">for</html:font></html:b> that purpose.
; NOTE 2: See the section on garbage collection below <html:b><html:font color="darkblue">if</html:font></html:b> you choose to
;         use subdirectories <html:b><html:font color="darkblue">for</html:font></html:b> session storage
session.save_path = /var/sessions

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path <html:b><html:font color="darkblue">for</html:font></html:b> which the cookie is valid.
session.cookie_path = /

; The domain <html:b><html:font color="darkblue">for</html:font></html:b> which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data.  php is the standard serializer of PHP.
session.serialize_handler = php

; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.

session.gc_probability = 1
session.gc_divisor     = 100

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; NOTE: If you are using the subdirectory option <html:b><html:font color="darkblue">for</html:font></html:b> storing session files
;       (see session.save_path above), then garbage collection does *not*
;       happen automatically.  You will need to do your own garbage 
;       collection through a shell script, cron entry, or some other method. 
;       For example, the following script would is the equivalent of
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
;          cd /path/to/sessions; find -cmin +24 | xargs rm
; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, albeit register_globals
; is disabled.  PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning seperately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled.

session.bug_compat_42 = 1
session.bug_compat_warn = 1

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring <html:b><html:font color="darkblue">for</html:font></html:b> the session to be
; considered as valid.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 12

; Specified here to create the session id.
session.entropy_file = /dev/urandom

;session.entropy_length = 16

;session.entropy_file = /dev/urandom
; Set to {nocache,private,public,} to determine HTTP caching aspects
; or leave this empty to avoid sending anti-caching headers.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180

; trans sid support is disabled by default.
; Use of trans sid may risk your users security. 
; Use this option with caution.
; - User may send URL contains active session ID
;   to other person via. email/irc/etc.
; - URL that contains active session ID may be stored
;   in publically accessible computer.
; - User may access your site with the same session ID
;   always using URL stored in browser's history or bookmarks.
session.use_trans_sid = 0
</html:pre></html:pre></html:div>

<html:p>

Please check your PHP manual for more information about this parameters.
<html:br/>
<html:br/>
</html:p><html:h2>
3. PHP as a module (not supported anymore)
</html:h2>
Some documentation (eg the one from&#xA0;PHP) may give some instructions for building and using PHP as a module. &#xA0; However, embedded PHP does not work well in a threaded environment. It neither work on Apache 2.0 and this won't be fixed in the forseeable future (a few years at least&#xA0;according to Rasmus LERDORF) &#xA0;  While this may behave correctly while running Caudium unthreaded, this usage is not supported by the Caudium group anymore and won't be until this issue is not fixed on the&#xA0;PHP side.
<html:br/>
<html:br/>
Please use the CGI/FastCGI modes instead.&#xA0;
<html:br/>
<html:br/>
<html:h2>
4. Conclusion
</html:h2>
At the time of writing this document, the most stable way to use PHP is the CGI one. &#xA0;It is up to you to decide between stability and speed. But the difference between them is not so big, only stability may be an issue.
</html:div></atom:subtitle>
</atom:feed>
